Exports the extended certificate from the default certificate store.
Syntax:
- <lRetVal> = ediSecurities.ExportExtendedCertificate(<sSubjectName>, <sIssuerName>, <sHexSerialNumber>, <sKeyContainer>, <lKeySpec>, <sFileName>, [<sServiceProvider>], [<lProviderType>])
Parameters:
- sSubjectName – Subject name of certificate to export.
- sIssuerName – Issuer name of certificate.
- sHexSerialNumber – Serial number of the certificate in hexadecimal notation.
- sKeyContainer – Key container name containing private key associated to certificate.
- lKeySpec – Key type of key container.
- sFileName – Full path and name of export file to create. If the file already exists, it will be overwritten without warning.
- sServiceProvider – Optional. Cryptographic Service Provider (CSP) that has the key container in its database. If none is specified, the default CSP is used.
- lProviderType – Optional. CSP type. If none is specified then the default provider type is used. If the sServiceProvider name has been specified then the provider type of that service provider is used. For the list of possible provider types please see Cryptographic Service Provider Type Constants.
Returns:
Returns 1 if the operation is successful; otherwise returns 0 if the operation fails.
Remarks:
The sSubjectName, sIssuerName and sHexSerialNumber are used to search for the certificate in the certificate store. See Locating a Digital Certificate.
The default certificate store is specified by the properties DefaultCertSystemStoreName and DefaultCertSystemStoreLocation.
The sServiceProvider and lProviderType specify the CSP that has the key container. If sServiceProvider and/or lProviderType are not specified, the default CSP database is used, which is specified by DefaultProviderName andServiceProviderType. The type of database, whether machine key set or user key set, is specified using ediDocument.Option by the constant OptDocument_MachineKeySet.
Example:
Dim oEdiDoc As Fredi.ediDocument
Dim oSecurities As Fredi.ediSecurities
' Create instance of Framework EDI.
Set oEdiDoc = New Fredi.ediDocument
' Get securities object.
Set oSecurities = oEdiDoc.GetSecurities
' Set the default certificate store
oSecurities.DefaultCertSystemStoreName = "My" ' Case sensitive
' Set the default certificate store location
oSecurities.DefaultCertSystemStoreLocation = "CurrentUser"
' Export test extended certificate.
If oSecurities.ExportExtendedCertificate("Edidev Test Certificate", "Edidev Test Certificate", "", "EdidevTestKeyContainer", CspKeyType_KEYEXCHANGE, App.Path & "\MyExportedTestCert.cer") = 1 Then
MsgBox "Successfully exported test certificate 'Edidev Test Certificate' to MyExportedTestCert.cer."Else
MsgBox "Failed to create certificate"End If
Sample